<template>
	<div class="card-fill layout-padding" v-loading="loading" element-loading-text="Loading...">
		<el-card shadow="hover" class="layout-padding-auto create-form">
			<el-form ref="formRef" :model="stateData.vmModel" :rules="formRules" label-width="120px">
				<div class="form-section">
					<div class="section-title">
						<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
						<span>单据信息</span>
					</div>

					<el-row :gutter="20">
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item ref="Entity_BillCode_FormItem" prop="Entity.BillCode">
								<template #label>
									<WtmLabelTooltip label="单据编号" tooltip="单据编号" />
								</template>
								<el-input v-model="stateData.vmModel.Entity.BillCode" clearable class="width100" disabled placeholder="自动生成"></el-input>
							</el-form-item>
						</el-col>
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item ref="Entity_Remark_FormItem" prop="Entity.Remark">
								<template #label>
									<WtmLabelTooltip label="备注" tooltip="备注" />
								</template>
								<el-input v-model="stateData.vmModel.Entity.Remark" clearable class="width100"></el-input>
							</el-form-item>
						</el-col>
					</el-row>
				</div>

				<div class="form-section">
					<div class="section-title">
						<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
						<span>申请人员信息</span>
					</div>

					<el-row :gutter="20">
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item
								ref="Entity_PersonId_FormItem"
								prop="Entity.PersonId"
								:rules="[{ required: true, message: '申请人员为必填项', trigger: 'blur' }]"
							>
								<template #label>
									<WtmLabelTooltip label="申请人员" tooltip="换班申请人员" />
								</template>
								<WtmPersonSelector v-model="stateData.vmModel.Entity.PersonId" :prefill-person="prefillPerson" @change="onPersonSelected" />
							</el-form-item>
						</el-col>
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item ref="Entity_StaffNo_FormItem" prop="Entity.StaffNo">
								<template #label>
									<WtmLabelTooltip label="员工工号" tooltip="申请人员工号" />
								</template>
								<el-input v-model="stateData.vmModel.Entity.StaffNo" clearable class="width100" disabled placeholder="选取人员后带入"></el-input>
							</el-form-item>
						</el-col>
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item ref="Entity_Name_FormItem" prop="Entity.Name">
								<template #label>
									<WtmLabelTooltip label="员工姓名" tooltip="申请人员姓名" />
								</template>
								<el-input v-model="stateData.vmModel.Entity.Name" clearable class="width100" disabled placeholder="选取人员后带入"></el-input>
							</el-form-item>
						</el-col>
					</el-row>
				</div>

				<div class="form-section">
					<div class="section-title">
						<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
						<span>换班对象信息</span>
					</div>

					<el-row :gutter="20">
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item
								ref="Entity_SwapPersonId_FormItem"
								prop="Entity.SwapPersonId"
								:rules="[{ required: true, message: '换班对象为必填项', trigger: 'blur' }]"
							>
								<template #label>
									<WtmLabelTooltip label="换班对象" tooltip="换班对象人员" />
								</template>
								<WtmPersonSelector
									v-model="stateData.vmModel.Entity.SwapPersonId"
									:prefill-person="prefillSwapPerson"
									:exclude-person-ids="[stateData.vmModel.Entity.PersonId]"
									:group-id="stateData.vmModel.Entity.GroupId"
									@change="onSwapPersonSelected"
								/>
							</el-form-item>
						</el-col>
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item ref="Entity_SwapStaffNo_FormItem" prop="Entity.SwapStaffNo">
								<template #label>
									<WtmLabelTooltip label="换班人工号" tooltip="换班对象人员工号" />
								</template>
								<el-input
									v-model="stateData.vmModel.Entity.SwapStaffNo"
									clearable
									class="width100"
									disabled
									placeholder="选取换班对象后带入"
								></el-input>
							</el-form-item>
						</el-col>
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item ref="Entity_SwapName_FormItem" prop="Entity.SwapName">
								<template #label>
									<WtmLabelTooltip label="换班人姓名" tooltip="换班对象人员姓名" />
								</template>
								<el-input v-model="stateData.vmModel.Entity.SwapName" clearable class="width100" disabled placeholder="选取换班对象后带入"></el-input>
							</el-form-item>
						</el-col>

						<!-- 换班对方排班记录选择 -->
						<el-col v-if="stateData.vmModel.Entity.SwapPersonId" :xs="24" :lg="12" class="mb20">
							<el-form-item
								label="换班对方排班记录"
								prop="Entity.SwapShiftId"
								:rules="[{ required: true, message: '换班对方排班记录为必填项', trigger: 'blur' }]"
							>
								<template #label>
									<WtmLabelTooltip label="换班对方排班记录" tooltip="选择换班对方的排班记录" />
								</template>
								<el-select
									v-model="stateData.vmModel.Entity.SwapShiftId"
									placeholder="请选择排班记录"
									class="width100"
									:loading="swapPersonShiftLoading"
									:disabled="swapPersonShiftOptions.length === 0 && !swapPersonShiftLoading"
									clearable
								>
									<el-option v-for="option in swapPersonShiftOptions" :key="option.value" :label="option.label" :value="option.value" />
									<el-option
										v-if="swapPersonShiftOptions.length === 0 && !swapPersonShiftLoading"
										value=""
										label="该人员暂无可用的排班记录"
										disabled
									/>
								</el-select>
							</el-form-item>
						</el-col>
					</el-row>
				</div>

				<div class="form-section">
					<div class="section-title">
						<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
						<span>换班信息</span>
					</div>

					<el-row :gutter="20">
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item
								ref="Entity_StartTime_FormItem"
								prop="Entity.StartTime"
								:rules="[{ required: true, message: '换班时间为必填项', trigger: 'blur' }]"
							>
								<template #label>
									<WtmLabelTooltip label="换班时间" tooltip="换班时间" />
								</template>
								<el-date-picker
									v-model="stateData.vmModel.Entity.StartTime"
									type="date"
									:disabled-date="disabledDate"
									clearable
									class="width100"
									placeholder="请选择换班时间"
								></el-date-picker>
							</el-form-item>
						</el-col>
						<!-- <el-col :xs="24" :lg="12" class="mb20">
							<el-form-item
								ref="Entity_EndTime_FormItem"
								prop="Entity.EndTime"
								:rules="[{ required: true, message: '结束时间为必填项', trigger: 'blur' }]"
							>
								<template #label>
									<WtmLabelTooltip label="结束时间" tooltip="换班结束时间" />
								</template>
								<el-date-picker
									v-model="stateData.vmModel.Entity.EndTime"
									type="date"
									:disabled-date="disabledDate"
									clearable
									class="width100"
									placeholder="请选择结束时间"
								></el-date-picker>
							</el-form-item>
						</el-col> -->
						<el-col :xs="24" :lg="12" class="mb20">
							<el-form-item ref="Entity_Reason_FormItem" prop="Entity.Reason" :rules="[{ required: true, message: '事由为必填项', trigger: 'blur' }]">
								<template #label>
									<WtmLabelTooltip label="事由" tooltip="换班事由" />
								</template>
								<el-input
									v-model="stateData.vmModel.Entity.Reason"
									type="textarea"
									:rows="2"
									clearable
									class="width100"
									placeholder="请输入换班事由"
								></el-input>
							</el-form-item>
						</el-col>
					</el-row>
				</div>

				<div class="form-section">
					<div class="section-title">
						<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
						<span>工作信息</span>
					</div>
					<el-row :gutter="20">
						<el-col :xs="24" :lg="12" class="mb20">
							<WtmOrgSelector
								v-model="stateData.vmModel.Entity.OrgId"
								label="公司"
								prop="Entity.OrgId"
								:auth="false"
								:disabled="true"
								placeholder="选取人员后带入"
							/>
						</el-col>
						<el-col :xs="24" :lg="12" class="mb20">
							<WtmDeptSelector v-model="stateData.vmModel.Entity.GroupId" prop="Entity.GroupId" label="所属部门" :auth="false" :disabled="true" />
						</el-col>
					</el-row>
				</div>
			</el-form>
		</el-card>
	</div>
</template>

<script setup lang="ts" name="message._system.common.vm.edit;false">
import ElMessage from 'element-plus/es/components/message/index';
import { reactive, ref, getCurrentInstance, onMounted, computed, nextTick, type ComponentInternalInstance } from 'vue';
import { SysDailyShiftSwapRequestBillApi as api } from '/@/views/daily/sysdailyshiftswaprequestbill/api';
import other from '/@/utils/other';
import { useRouter } from 'vue-router';
import { ISysDailyShiftSwapRequestBillVm } from '/@/views/daily/sysdailyshiftswaprequestbill/api/interface';
import { IViewModel } from '/@/types/common';
import { SysAttendanceRecordApi as attendanceApi } from '/@/views/hr/sysattendancerecord/api';
import type { ISearchByPersonRequest } from '/@/views/hr/sysattendancerecord/api/interface';
import { formatDate } from '/@/utils/formatTime';

/**
 * ===== 常量定义区域 =====
 * 统一管理业务常量，便于维护和复用
 */

/** 单据状态枚举 */
const BILL_STATUS = {
	DRAFT: '草稿', // 草稿状态，可编辑
	FORMAL: '正文', // 正式状态，不可编辑
	IN_AUDIT: '审核中', // 审批中状态
} as const;

/** 工作流状态枚举 */
const WORKFLOW_STATUS = {
	PENDING: '待提交', // 初始状态，等待提交
	SUBMITTING: '提交中', // 正在提交流程
	IN_AUDIT: '审核中', // 审批流程中
	COMPLETED: '已完成', // 流程完成
	CANCELLED: '已取消', // 流程取消
} as const;

/**
 * ===== 按钮文本常量 =====
 */
const BUTTON_TEXTS = {
	SAVE: '保存',
	SUBMIT: '提交',
	AGREE: '同意',
	REJECT: '拒绝',
	CLOSE: '关闭',
} as const;

/**
 * ===== 审批动作常量 =====
 */
const ACTIONS = {
	AGREE: '同意',
	REJECT: '拒绝',
} as const;

/**
 * ===== API接口路径常量 =====
 */
const API_ENDPOINTS = {
	GROUPS: '/api/SysDailyShiftSwapRequestBill/GetSysGroups',
} as const;

/**
 * ===== 组件实例和基础配置 =====
 */

/** 组件实例，用于访问组件上下文 */
const ci = getCurrentInstance() as ComponentInternalInstance;

/** 页面加载状态控制 */
const loading = ref(false);

/** 表单组件引用 */
const formRef = ref();

/**
 * ===== 表单验证规则 =====
 * 动态计算的表单验证规则
 */
const formRules = computed(() => {
	const rules: Record<string, any[]> = {
		'Entity.PersonId': [{ required: true, message: '请选择申请人员', trigger: 'change' }],
		'Entity.SwapPersonId': [{ required: true, message: '请选择换班对象', trigger: 'change' }],
		'Entity.StartTime': [{ required: true, message: '请选择开始时间', trigger: 'change' }],
		'Entity.EndTime': [{ required: true, message: '请选择结束时间', trigger: 'change' }],
		'Entity.Reason': [{ required: true, message: '请输入事由', trigger: 'blur' }],
	};

	return rules;
});

/**
 * ===== 响应式状态数据 =====
 */

/** 表单数据状态 */
const stateData = reactive<IViewModel<ISysDailyShiftSwapRequestBillVm>>({
	vmModel: {
		Entity: {
			ID: null,
			PersonId: null,
			OrgId: null,
			StaffNo: null,
			Name: null,
			StartTime: null,
			EndTime: null,
			Reason: null,
			SwapPersonId: null,
			SwapStaffNo: null,
			SwapName: null,
			Approver: null,
			ApprovalTime: null,
			GroupId: null,
			BillCode: null,
			BillStatus: null,
			WorkflowStatus: null,
			Remark: null,
			SwapShiftId: null,
		} as any, // 使用类型断言来支持额外字段
		ActionName: null,
		IsMyApprove: null,
	},
	AllSysGroups: [] as any[], // 所有部门组织数据
});

// 排班记录相关状态
const swapPersonShiftLoading = ref(false); // 换班对方排班记录加载状态
const swapPersonShiftOptions = ref<Array<{ value: string; label: string }>>([]); // 换班对方排班记录选项

/**
 * ===== 业务逻辑计算属性 =====
 */

/** 日期限制：前后60天 */
const disabledDate = computed(() => {
	return (time: Date) => {
		const today = new Date();
		const sixtyDaysAgo = new Date(today.getTime() - 60 * 24 * 60 * 60 * 1000);
		const sixtyDaysLater = new Date(today.getTime() + 60 * 24 * 60 * 60 * 1000);
		return time < sixtyDaysAgo || time > sixtyDaysLater;
	};
});

/** 计算是否有实体ID */
const hasEntityId = computed(() => {
	const entity = stateData.vmModel.Entity as any;
	return !!(entity && entity.ID);
});

/** 是否处于审批状态 */
const isInAudit = computed(() => stateData.vmModel.Entity.WorkflowStatus === WORKFLOW_STATUS.IN_AUDIT);

/** 是否可以提交 - 草稿状态且等待提交 */
const canSubmit = computed(
	() =>
		stateData.vmModel.Entity.BillStatus === BILL_STATUS.DRAFT &&
		(!stateData.vmModel.Entity.WorkflowStatus || stateData.vmModel.Entity.WorkflowStatus === WORKFLOW_STATUS.PENDING)
);

/** 是否可以审批 - 有审批权限且处于审批状态 */
const canApprove = computed(() => !!stateData.vmModel.IsMyApprove && isInAudit.value);

/** 申请人员回显数据 - 用于人员选择器的数据回显 */
const prefillPerson = computed(() => {
	const entity = stateData.vmModel.Entity;
	if (entity.PersonId && entity.Name && entity.StaffNo) {
		return {
			ID: entity.PersonId,
			Name: entity.Name,
			StaffNo: entity.StaffNo,
		};
	}
	return null;
});

/** 换班对象回显数据 - 用于换班对象选择器的数据回显 */
const prefillSwapPerson = computed(() => {
	const entity = stateData.vmModel.Entity;
	if (entity.SwapPersonId && entity.SwapName && entity.SwapStaffNo) {
		return {
			ID: entity.SwapPersonId,
			Name: entity.SwapName,
			StaffNo: entity.SwapStaffNo,
		};
	}
	return null;
});

/**
 * ===== 工具函数 =====
 */

/** 统一的成功处理函数 - 处理操作成功后的通用逻辑 */
const handleSuccess = (response: any, isSubmit = false) => {
	// 根据操作类型显示不同的消息
	if (isSubmit) {
		ElMessage.success(ci.proxy?.$t('message._system.common.vm.submittip') || '提交成功');
		emit('refresh');
		closeDialog();
	} else {
		ElMessage.success(ci.proxy?.$t('message._system.common.vm.savetip') || '保存成功');
		emit('refresh');
		// 保存后不关闭弹窗，更新实体ID
		if (response?.Entity?.ID) {
			stateData.vmModel.Entity = response.Entity;
		} else if (response?.ID) {
			(stateData.vmModel.Entity as any).ID = response.ID;
		}
	}

	loading.value = false;
	nextTick(() => {
		setupHeaderButtons();
	});
};

/** 统一的错误处理函数 - 处理API调用失败等错误情况 */
const handleError = (error: any) => {
	other.setFormError(ci, error);
	loading.value = false;
};

/** 公共的API请求处理函数 - 统一处理表单验证和API调用 */
const handleApiRequest = (apiCall: () => Promise<any>, beforeSubmit: () => void, isSubmit = false) => {
	other.validateFormWithMessage(formRef.value, () => {
		loading.value = true;
		beforeSubmit();
		apiCall()
			.then((response: any) => handleSuccess(response, isSubmit))
			.catch(handleError);
	});
};

/** 公共的审批处理函数 - 处理审批操作的通用逻辑 */
const handleApproval = (actionName: string) => {
	stateData.vmModel.ActionName = actionName;
	loading.value = true;
	formRef.value?.validate((valid: boolean) => {
		if (valid) {
			api()
				.approve(stateData.vmModel, '')
				.then(() => handleSuccess(true))
				.catch(handleError);
		} else {
			loading.value = false;
		}
	});
};

/**
 * ===== 用户交互函数 =====
 */

/** 申请人员选择变化处理 - 选择申请员工时自动填充相关信息 */
const onPersonSelected = (value: any, person: any) => {
	if (person) {
		// 自动填充申请人员信息
		stateData.vmModel.Entity.StaffNo = person.StaffNo || '';
		stateData.vmModel.Entity.Name = person.Name || '';
		stateData.vmModel.Entity.OrgId = person.OrgId || '';
		stateData.vmModel.Entity.GroupId = person.GroupId || '';
	} else {
		// 清空申请人员信息
		stateData.vmModel.Entity.StaffNo = null;
		stateData.vmModel.Entity.Name = null;
		stateData.vmModel.Entity.OrgId = null;
		stateData.vmModel.Entity.GroupId = null;
	}

	// 清空换班对方人员信息（因为部门可能已改变，或者需要重新选择）
	stateData.vmModel.Entity.SwapPersonId = null;
	stateData.vmModel.Entity.SwapStaffNo = null;
	stateData.vmModel.Entity.SwapName = null;
	// 清空排班记录
	swapPersonShiftOptions.value = [];
	stateData.vmModel.Entity.SwapShiftId = null;
};

/** 换班对象选择变化处理 - 选择换班对象时自动填充相关信息 */
const onSwapPersonSelected = async (value: any, person: any) => {
	if (person) {
		// 自动填充换班对象信息
		stateData.vmModel.Entity.SwapStaffNo = person.StaffNo || '';
		stateData.vmModel.Entity.SwapName = person.Name || '';

		// 加载该人员的排班记录（不保留之前选中的值）
		await loadSwapPersonScheduleRecords(value, false);
	} else {
		// 清空换班对象信息
		stateData.vmModel.Entity.SwapStaffNo = null;
		stateData.vmModel.Entity.SwapName = null;

		// 清空排班记录
		swapPersonShiftOptions.value = [];
		stateData.vmModel.Entity.SwapShiftId = null;
	}
};

// 查询换班对方排班记录
const loadSwapPersonScheduleRecords = async (personId: string, keepSelectedValue = false) => {
	try {
		swapPersonShiftLoading.value = true;
		// 如果不需要保留之前选中的值，则清空
		if (!keepSelectedValue) {
			stateData.vmModel.Entity.SwapShiftId = null;
		}
		swapPersonShiftOptions.value = [];

		// 构建查询参数 - 查询未来30天的排班记录
		const params: ISearchByPersonRequest = {
			PersonId: personId,
			Page: 1,
			Limit: 50,
			IsPlainText: true,
			IsEmunToString: true,
			ShiftDate: [formatDate(new Date(), 'yyyy-MM-dd'), formatDate(new Date(new Date().getTime() + 30 * 24 * 60 * 60 * 1000), 'yyyy-MM-dd')],
		};

		const response = await attendanceApi().getSchedulingByPerson(params);

		if (response.Data && Array.isArray(response.Data) && response.Data.length > 0) {
			const firstData = (response.Data as any[])[0];
			if (firstData && firstData.Records && Array.isArray(firstData.Records)) {
				const filteredData = firstData.Records.filter((record: any) => {
					return record.ID && record.ShiftDate && record.AttendanceShiftGroupName;
				});

				swapPersonShiftOptions.value = filteredData.map((record: any) => {
					const shiftName = record.AttendanceShift?.Name || record.AttendanceShiftGroupName || record.ShiftName || record.ShiftInfo || '未知班次';
					return {
						value: record.ID,
						label: `${record.ShiftDate} - ${shiftName}`,
					};
				});
			}
		}

		if (swapPersonShiftOptions.value.length === 0) {
			ElMessage.info('该人员暂无可用的排班记录');
		}
	} catch (error) {
		console.error('查询换班对方排班记录失败:', error);
		ElMessage.error('查询换班对方排班记录失败');
		swapPersonShiftOptions.value = [];
	} finally {
		swapPersonShiftLoading.value = false;
	}
};

/**
 * ===== 用户操作函数 =====
 */

/** 关闭对话框 */
const onClose = () => {
	closeDialog();
};

/** 保存操作 - 保存为草稿状态 */
const onSave = () => {
	handleApiRequest(
		() => api().edit(stateData.vmModel),
		() => {
			stateData.vmModel.Entity.BillStatus = BILL_STATUS.DRAFT;
		},
		false // 保存后不关闭弹窗
	);
};

/** 提交操作 - 提交到审批流程 */
const onSubmit = () => {
	handleApiRequest(
		() => api().edit(stateData.vmModel),
		() => {
			// 提交前设置状态
			stateData.vmModel.Entity.BillStatus = BILL_STATUS.FORMAL;
			stateData.vmModel.Entity.WorkflowStatus = WORKFLOW_STATUS.SUBMITTING;
		},
		true // 提交后关闭弹窗
	);
};

/** 审批同意 */
const onAgree = () => {
	handleApproval(ACTIONS.AGREE);
};

/** 审批拒绝 */
const onDeny = () => {
	handleApproval(ACTIONS.REJECT);
};

/**
 * ===== 页面初始化函数 =====
 */

/** 初始化页面数据 - 从路由参数或传入数据中获取实体ID */
const initializePageData = () => {
	const wtmdata = ci.attrs['wtmdata'] as any;
	const routeId = useRouter().currentRoute.value.query.id;

	if (wtmdata?.ID) {
		stateData.vmModel.Entity.ID = wtmdata.ID;
	} else if (routeId) {
		stateData.vmModel.Entity.ID = routeId as any;
	}
};

/** 加载页面数据 - 并行获取部门数据和实体数据 */
const loadPageData = async () => {
	const [groups, entityData] = await Promise.allSettled([
		other.getSelectList(API_ENDPOINTS.GROUPS, [], false), // 获取部门列表
		api().get(stateData.vmModel.Entity.ID ?? ''), // 获取实体详情
	]);

	// 处理成功的结果
	if (groups.status === 'fulfilled') stateData.AllSysGroups = groups.value;
	if (entityData.status === 'fulfilled') {
		other.setValue(stateData.vmModel, entityData.value);
		// 如果有换班对方人员，则加载其排班记录（保留已选中的值）
		if (stateData.vmModel.Entity.SwapPersonId) {
			await loadSwapPersonScheduleRecords(stateData.vmModel.Entity.SwapPersonId, true);
		}
	}
};

/**
 * ===== 生命周期钩子 =====
 */

/** 组件挂载时执行 - 初始化页面数据 */
onMounted(async () => {
	loading.value = true;
	initializePageData();

	try {
		await loadPageData();
	} catch (error) {
		other.setFormError(ci, error);
	} finally {
		loading.value = false;
		nextTick(() => {
			setupHeaderButtons(); // 设置头部按钮
		});
	}
});

/**
 * ===== 组件通信 =====
 */

/** 定义子组件向父组件传值/事件 */
const emit = defineEmits(['refresh', 'closeDialog', 'updateHeaderButtons']);

/** 关闭弹窗 */
const closeDialog = () => {
	emit('closeDialog');
};

/** 设置对话框头部按钮 - 根据当前状态动态配置可用按钮 */
const setupHeaderButtons = () => {
	const headerButtons = [
		{
			text: BUTTON_TEXTS.SAVE,
			type: undefined,
			onClick: onSave,
			visible: !isInAudit.value, // 非审批状态时显示保存按钮
		},
		{
			text: BUTTON_TEXTS.SUBMIT,
			confirm: '提交单据以后无法修改，是否确认提交?',
			type: 'primary',
			onClick: onSubmit,
			visible: canSubmit.value && !isInAudit.value, // 草稿状态且非审批时显示提交
		},
		{
			text: BUTTON_TEXTS.AGREE,
			type: 'primary',
			onClick: onAgree,
			visible: canApprove.value, // 有审批权限时显示同意
		},
		{
			text: BUTTON_TEXTS.REJECT,
			type: 'danger',
			onClick: onDeny,
			visible: canApprove.value, // 有审批权限时显示拒绝
		},
		{
			text: BUTTON_TEXTS.CLOSE,
			type: 'default',
			onClick: onClose,
			visible: true,
		},
	];

	emit('updateHeaderButtons', headerButtons);
};
</script>
